import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * @author Garima 
 *
 * Test cases for VendingMachineItem
 *
 */

public class VendingMachineItemTest {
	public VendingMachine myMachine;
	public VendingMachineItem item1;
	public VendingMachineItem item2;
	public VendingMachineItem item3;

	
	@Before
	public void setUp() throws Exception {
		item1 = new VendingMachineItem ("Snickers", 1.25);
		item2 = new VendingMachineItem ("Cookies", 1.00);

	}
	@After
	public void tearDown() throws Exception {
		
	}

	/**
	 * Test vending machine item constructor for not null object.
	 *
	 */
	@Test
	public void VendingMachineItem_NotNull() {
		assertNotNull(item1);	 
	}

	/**
	 * Test vending machine item constructor with null name.
	 */
	@Test 
	public void VendingMachineItem_NullName() {
		new VendingMachineItem(null, 1.00);
	}

	
	/**
	 * Test vending machine item constructor with empty string.
	 */
	@Test 
	public void VendingMachineItem_EmptyString() {
		new VendingMachineItem(" ", 1.00);
	}


	/**
	 * Test the getName() of the vending machine item -  the actual name of the item should be matched.
	 * Postcondition:Returns true if the string corresponding to the name of the vending machine item matches the testing result.
	 */
	@Test
	public void getName_checkName1() {
		assertEquals("Cookies", item2.getName());
	}

	/**
	 * Test getPrice() of Vending Machine with margin
	 * Postcondition: Expected and actual price should match. Returns true for match.
	 */
	@Test
	public void getPrice_with_margin() {
		//Return True if the price corresponding to the vending machine item passed.
		assertEquals(1.001, item2.getPrice(), 0.001);
	}

}